Setting Up the Parameters for Printing
QuickDraw GX sends theGXSetupImageData
message so that you can initialize any constant data that your driver needs to use for imaging a document. The ImageWriter II driver overrides this message with theSD_SetupImageData
function, which sets up the following data for a print job:
The
- the draft character table for printing in text mode
- halftone data for printing in graphics mode
- the start-of-page string for unidirectional or bidirectional printing, depending on the print quality of the print job
- the raster packaging information, which is different for different qualities of printing
- print-quality information
- color-printing information
GXSetupImageData
message is described on page 4-92 in the chapter "Printing Messages." A portion of theSD_SetupImageData
function is shown in Listing 3-11. The complete version of this function is found in the QuickDraw GX sample code.Listing 3-11 Setting up the constant data for the print job
OSErr SD_SetupImageData( gxRasterImageDataHdl hImageData ) { OSErr anErr; gxRasterImageDataPtr pImageData; Boolean isJobNotFinalQuality, isTextJobFormatMode; long imagewriterOptions; /* do the default setup */ anErr = Forward_GXSetupImageData(hImageData); nrequire(anErr, Forward_GXSetupImageData); /* test for 'final' quality mode */ isJobNotFinalQuality = !JobIsBest(&imagewriterOptions); /* test for gxTextJobFormatMode */ isTextJobFormatMode = ( GXGetJobFormatMode( GXGetJob() ) == gxTextJobFormatMode); /* If the job is not final quality and is not using text mode, downgrade the imaging data to lower quality. */ if (isJobNotFinalQuality || isTextJobFormatMode) { /* rough or text mode */ pImageData = *hImageData; /* dereference for size+speed */ /* image at 80 or 72 dpi */ if (imagewriterOptions & kSuperRes) pImageData->hImageRes = ff(80); else pImageData->hImageRes = ff(72); pImageData->vImageRes = ff(72); /* If using text mode, load the draft table; otherwise, set up the halftone data. */ if (isTextJobFormatMode) { /* load the draft table */ Handle draftTable; SpecGlobalsHdl hGlobals = GetMessageHandlerInstanceContext(); anErr = Send_GXFetchTaggedDriverData('idft', gxPrintingDriverBaseID, &draftTable); nrequire(anErr, FailedToLoadDraftTable); (**hGlobals).draftTable = draftTable; } else { /* Use dither level that looks better at 72 dpi than do the default values from the resources. */ pImageData->theSetup.planeSetup[0].planeHalftone.method = 4; /* turn off color matching when in non-final mode */ pImageData->theSetup.planeSetup[0].planeProfile = nil; } ...The remainder of theSD_SetupImageData
function operates similarly, modifying the default values for varying resolution values.The
JobIsBest
function that is called bySD_SetupImageData
accesses the job collection to establish the print quality. The code for this function is shown in
Listing 3-12. The quality information is stored as an item in the job collection that specifies how the user wants the job printed. This information is accessed from the job collection using thegxQualityTag
tag ID.Listing 3-12 Establishing the print quality
Boolean JobIsBest(long *imagewriterOptions) { Boolean isFinal; gxQualityInfo jobQualitySettings; long itemSize = sizeof(jobQualitySettings); OSErr status; Collection jobCollection; /* cache the collection */ jobCollection = GXGetJobCollection(GXGetJob()); isFinal = false; status = GetCollectionItem(jobCollection, gxQualityTag, gxPrintingTagID, &itemSize, &jobQualitySettings); if ( (status == noErr) && (jobQualitySettings.currentQuality == (jobQualitySettings.qualityCount-1)) ) isFinal = true; /* default is kSuperRes */ *imagewriterOptions = kSuperRes; itemSize = sizeof(imagewriterOptions); status = GetCollectionItem(jobCollection, DriverCreator, 0, &itemSize, imagewriterOptions); return(isFinal); }TheJobIsBest
function returnstrue
if the current print job is printed in final quality; otherwise, it returnsfalse
. It also accesses and returns the ImageWriter II options from the job collection.
Main | Page One | What's New | Apple Computer, Inc. | Find It | Contact Us | Help